<template>
  <div>
    <!-- <div class="common_form_search">
      <el-form ref="searchForm" :inline="true" :model="searchForm">
        <el-form-item label="入驻商家姓名" prop="name">
          <el-input v-model="searchForm.name" placeholder="入驻商家姓名" clearable />
        </el-form-item>
        <el-form-item label="联系电话" prop="phone">
          <el-input v-model="searchForm.phone" placeholder="联系电话" clearable />
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click="search()">查询</el-button>
          <el-button size="small" @click="reset()">重置</el-button>
        </el-form-item>
      </el-form>
    </div> -->
    <!-- <el-divider /> -->
    <div class="flex align-center table-top-btns">
      <h5 class="flex align-center">
        <svg-icon style="margin-right:15px" icon-class="list" :size="15" />数据列表
      </h5>
    </div>
    <el-table v-show="tableData.length > -1" :data="tableData" border>
      <el-table-column align="center" prop="name" label="入驻商家姓名" width="300" />
      <el-table-column align="center" prop="mobile" label="联系电话" />
      <el-table-column align="center" prop="area" label="所在地区" />
      <el-table-column align="center" label="主要产品名称" prop="product" />
      <el-table-column align="center" label="申请时间" prop="create_at" />
      <el-table-column align="center" label="备注" prop="remark" />
      <el-table-column fixed="right" align="center" label="操作" width="240">
        <template slot-scope="scope">
          <el-button type="primary" plain @click="handleRemark(scope.row.id)">添加备注</el-button>
        </template>
      </el-table-column>
    </el-table>
    <custom-page ref="customPage" :total="total" @getList="getList" />
    <set-remark ref="setRemark" :apply-id="applyId" @getList="getList" />
  </div>
</template>

<script>
import { supplierApplyList } from '@/api/user'
import customPage from '@/components/customPage'
import setRemark from './components/setRemark'
export default {
  components: { customPage, setRemark },
  props: {
    shopname: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      searchForm: {
        name: '',
        phone: ''
      },
      total: 0,
      tableData: [],
      routerName: '',
      applyId: ''
    }
  },
  created() {
    if (this.$route.query.shopname) {
      this.routerName = this.$route.query.shopname
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    handleRemark(id) {
      this.applyId = id
      this.$refs.setRemark.dialogVisible = true
    },
    // 查询
    search() {
      this.$refs.customPage.page = 1
      this.getList()
    },
    // 重置
    reset() {
      this.searchForm = {
        shopname: '',
        account_num: '',
        status: null
      }
      this.routerName = ''
      this.getList()
    },
    getList(flag) {
      // flag为true, 则不刷新表格
      const { page, pageSize } = this.$refs.customPage
      if (!flag) {
        this.tableData = []
      }
      supplierApplyList({ page, pageSize, ...this.searchForm }).then(res => {
        this.tableData = res.data || []
        this.total = res.total
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
